package com.cloudminds.nativeapplication.ble;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;

import no.nordicsemi.android.ble.BleManager;
import no.nordicsemi.android.ble.BleManagerCallbacks;

/**
 * @Description TODO
 * Created by sain on 2021/3/8 Monday.
 * Copyright © 2020 AISpeech. All rights reserved.
 * ================================================================================
 */
public abstract class RemoteVoiceBleManger extends BleManager implements BleManagerCallbacks {
    private static final String TAG = "RemoteVoiceBleManger";
    private Context mContext;

    /**
     * The manager constructor.
     * <p>
     * After constructing the manager, the callbacks object must be set with
     * {@link #setGattCallbacks(BleManagerCallbacks)}.
     * <p>
     * To connect a device, call {@link #connect(BluetoothDevice)}.
     *
     * @param context context
     */
    public RemoteVoiceBleManger(@NonNull Context context) {
        super(context);
        setGattCallbacks(this);
        mContext = context;
    }

    protected abstract BluetoothDevice getTargetDevice();

    public void start() {
        Log.d(TAG, "start: ");
        BluetoothDevice device = getTargetDevice();
        connect(device);
    }

    public void stop() {
        Log.d(TAG, "stop: ");
        if (isConnected()) {
            disconnect();
        }
    }

    @Override
    public void onDeviceConnecting(BluetoothDevice device) {

    }

    @Override
    public void onDeviceConnected(BluetoothDevice device) {

    }

    @Override
    public void onDeviceDisconnecting(BluetoothDevice device) {

    }

    @Override
    public void onDeviceDisconnected(BluetoothDevice device) {

    }

    @Override
    public void onLinklossOccur(BluetoothDevice device) {

    }

    @Override
    public void onServicesDiscovered(BluetoothDevice device, boolean optionalServicesFound) {

    }

    @Override
    public void onDeviceReady(BluetoothDevice device) {

    }

    @Override
    public boolean shouldEnableBatteryLevelNotifications(BluetoothDevice device) {
        return false;
    }

    @Override
    public void onBatteryValueReceived(BluetoothDevice device, int value) {

    }

    @Override
    public void onBondingRequired(BluetoothDevice device) {

    }

    @Override
    public void onBonded(BluetoothDevice device) {

    }

    @Override
    public void onError(BluetoothDevice device, String message, int errorCode) {

    }

    @Override
    public void onDeviceNotSupported(BluetoothDevice device) {

    }
}
